#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QPainter>
#include <QMouseEvent>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include "weatherdata.h"
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QLabel>
#include <QMessageBox>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

protected:
    void contextMenuEvent(QContextMenuEvent *event);//重写父类右键菜单事件

//    void paintEvent(QPaintEvent *);

    void mousePressEvent(QMouseEvent* ev); //鼠标点击事件
    void mouseMoveEvent(QMouseEvent* ev);  //鼠标移动事件

    void getWeatherInfo(QString cityCode); //获取天气信息

    void parseJson(QByteArray& byteArray); //解析json
    void updateUI();  //更新UI

    bool eventFilter(QObject* watched, QEvent* event);

    void paintHighCurve();
    void paintLowCurve();

private slots:


    void onReplied(QNetworkReply* reply);

    void on_btnSearch_clicked();

private:
    Ui::MainWindow *ui;

    QMenu* mExitMenu;   //右键退出的菜单
    QAction* mExitAct;  //菜单项

    QPoint mOffset;     //鼠标与应用窗口左上角的距离

    //http请求
    QNetworkAccessManager* mNetworkAccessManager;

    Today mToday;
    Day mDay[6];

    //控件数组
    QList<QLabel*> mWeekList;
    QList<QLabel*> mDateList;

    QList<QLabel*> mTypeList;
    QList<QLabel*> mTypeIconList;

    QList<QLabel*> mAqiList;

    QList<QLabel*> mFxList;
    QList<QLabel*> mFlList;

    //天气图片
    QMap<QString, QString> mTypeMap;

};
#endif // MAINWINDOW_H
